/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package factory;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.Timer;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Rectangle;

/**
 *
 * @author wida46984148
 */
public class NauBoss extends NauEnemiga{

    boolean enemigo = true;
    Timer timer;
    aux2 a;
    Shoot shoot2 = null;
    Shoot shoot3 = null;
    Shoot msE = null;
    Shoot msE2 = null;
    Shoot msE3 = null;
    Shoot msE4 = null;
    NauBase nbE = null;
    boolean disparando = true;

    public NauBoss(float vida, float vidaT, Shoot shoot, Shoot shoot2, Shoot shoot3, Image nau, float posX, float posY, Image nauDestroy) {
        super(vida, vidaT, shoot, nau, nauDestroy);
        super.posX = posX;
        super.posY = posY;
        sbe = new ArrayList<Shoot>();
        this.shoot2 = shoot2;
        this.shoot3 = shoot3;
    }

    @Override
    public void setLocation(float posX, float posY) {
        super.setLocation(posX, posY);
        super.shape = new Rectangle(posX, posY, nau.getWidth(), nau.getHeight());
    }

    @Override
    public void render(GameContainer gc, Graphics g) {
        if(!(super.isMort())){
            g.drawImage(nau, posX, posY);
        }else{
            g.drawImage(nauDestroy, posX, posY);
        }
        for (Shoot n : sbe) {
            if (n != null) {
                n.render(gc, g);
            }
        }
    }

    @Override
    public void update(int delta) throws SlickException {
        if (!(destroy)) {
            if(posY < 50){
                posY += 2;
            }
            shape.setLocation(posX, posY);
            if (disparando) {
                disparando = false;
                timer = new Timer(600, new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        msE = shoot.copiarShoot();
                        msE.setLocation(posX+180, posY+40);
                        msE2 = shoot2.copiarShoot();
                        msE2.setLocation(posX+10, posY+40);
                        msE3 = shoot3.copiarShoot();
                        msE3.setLocation(posX+80, posY+40);
                        msE4 = shoot3.copiarShoot();
                        msE4.setLocation(posX+120, posY+40);
                        //a.posShootE(nbE.getPosX() + 58, nbE.getPosY() + 100, (shootE) msE);
                        sbe.add(msE);
                        sbe.add(msE2);
                        sbe.add(msE3);
                        sbe.add(msE4);
                        if (600 <= getPosY()) {
                            timer.stop();
                            destroy = true;
                        }
                    }
                });
            }
            timer.start();
        } else {
            posX = 1000;
            posY = 1000;
        }
        updateshoot(delta);
    }

    @Override
    public void updateshoot(int delta) {
        timer.start();
        for (Shoot n : sbe) {
            if (n != null) {
                n.update(delta);
            }
        }
    }
}


